FROM golang:1.13.5-alpine3.10 AS builder

WORKDIR /build

ENV GOPROXY https://goproxy.cn
COPY xiaoniu-registry/go.mod .
RUN go mod download

COPY xiaoniu-registry .
RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -a -o xiaoniu-registry cmd/server.go

FROM alpine:3.10 AS final

WORKDIR /app
COPY --from=builder /build/xiaoniu-registry /app/
COPY --from=builder /build/frontend /app/frontend
EXPOSE 9898
ENTRYPOINT ["/app/xiaoniu-registry"]